﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace Paper_Management_System
{
    public partial class QueryForm : Form
    {
        public MainForm paForm; 
        public QueryForm()
        {
            InitializeComponent();
            OnLoad();
        }
        private void OnLoad()
        {
            //界面设计，加载grdPapers的列信息
            DataGridViewTextBoxColumn colTitle = new DataGridViewTextBoxColumn();
            colTitle.HeaderText = "论文名";
            grdPapers.Columns.Add(colTitle);
            DataGridViewTextBoxColumn colAuthor = new DataGridViewTextBoxColumn();
            colAuthor.HeaderText = "作者";
            grdPapers.Columns.Add(colAuthor);
            DataGridViewTextBoxColumn colKeyWords = new DataGridViewTextBoxColumn();
            colKeyWords.HeaderText = "关键字";
            grdPapers.Columns.Add(colKeyWords);
            DataGridViewTextBoxColumn colAbstract = new DataGridViewTextBoxColumn();
            colAbstract.HeaderText = "摘要";
            grdPapers.Columns.Add(colAbstract);
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //查询结果存入临时变量
            string queryS = tbxSearch.Text;
            ArrayList tmpAL;
            tmpAL = this.paForm.ctnPaper.Query(queryS);
            //显示
            this.grdPapers.Rows.Clear();
            for (int i = 0; i < tmpAL.Count; i++)
            {
                IContainer.Itm tmp;
                tmp = (IContainer.Itm)tmpAL[i];
                this.grdPapers.Rows.Add();
                int curR = this.grdPapers.Rows.Count - 2;
                this.grdPapers[0, curR].Value = tmp.Title;
                this.grdPapers[1, curR].Value = tmp.Author;
                this.grdPapers[2, curR].Value = tmp.KeyWords;
                this.grdPapers[3, curR].Value = tmp.Abstract;
            }
        }
    }
}
